﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace ComicWeb.Models
{
    public partial class ShopContext : DbContext
    {
        public ShopContext()
        {
        }

        public ShopContext(DbContextOptions<ShopContext> options)
            : base(options)
        {
        }

        public virtual DbSet<ChapterConmentInfo> ChapterConmentInfos { get; set; }
        public virtual DbSet<ChapterInfo> ChapterInfos { get; set; }
        public virtual DbSet<ChapterLikesInfo> ChapterLikesInfos { get; set; }
        public virtual DbSet<CollectionInfo> CollectionInfos { get; set; }
        public virtual DbSet<ComicsDownInfo> ComicsDownInfos { get; set; }
        public virtual DbSet<ComicsInfo> ComicsInfos { get; set; }
        public virtual DbSet<ComicsTypeInfo> ComicsTypeInfos { get; set; }
        public virtual DbSet<ComicsUpInfo> ComicsUpInfos { get; set; }
        public virtual DbSet<ConmentInfo> ConmentInfos { get; set; }
        public virtual DbSet<ConmentLikesInfo> ConmentLikesInfos { get; set; }
        public virtual DbSet<CountryInfo> CountryInfos { get; set; }
        public virtual DbSet<HistoryInfo> HistoryInfos { get; set; }
        public virtual DbSet<TypeInfo> TypeInfos { get; set; }
        public virtual DbSet<UserInfo> UserInfos { get; set; }
        public virtual DbSet<VChapterInfo> VChapterInfos { get; set; }
        public virtual DbSet<VClassification> VClassifications { get; set; }
        public virtual DbSet<VComicsInfo> VComicsInfos { get; set; }
        public virtual DbSet<VComicsInfoGx> VComicsInfoGxes { get; set; }
        public virtual DbSet<VComicsInfoMx> VComicsInfoMxes { get; set; }
        public virtual DbSet<VComicsInfoSj> VComicsInfoSjs { get; set; }
        public virtual DbSet<proc_detailedClass> proc_detailedClass { get; set; }
        public virtual DbSet<proc_Classification> proc_Classifications { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=39.104.170.137,8082;Initial Catalog=ComicsDB;user id=sa;password=Lsl123456;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AI");

            modelBuilder.Entity<ChapterConmentInfo>(entity =>
            {
                entity.HasKey(e => e.ChapterConmentId)
                    .HasName("PK__ChapterC__6C2BC71E55A50F52");

                entity.ToTable("ChapterConmentInfo");

                entity.Property(e => e.ChapterConmentId).HasColumnName("ChapterConmentID");

                entity.Property(e => e.ChapterContent).HasMaxLength(200);

                entity.Property(e => e.ChapterId).HasColumnName("ChapterID");

                entity.Property(e => e.ChapterTime).HasMaxLength(30);

                entity.Property(e => e.UserId).HasColumnName("UserID");

                entity.HasOne(d => d.Chapter)
                    .WithMany(p => p.ChapterConmentInfos)
                    .HasForeignKey(d => d.ChapterId)
                    .HasConstraintName("FK__ChapterCo__Chapt__4316F928");

                entity.HasOne(d => d.User)
                    .WithMany(p => p.ChapterConmentInfos)
                    .HasForeignKey(d => d.UserId)
                    .HasConstraintName("FK__ChapterCo__UserI__4222D4EF");
            });

            modelBuilder.Entity<ChapterInfo>(entity =>
            {
                entity.HasKey(e => e.ChapterId)
                    .HasName("PK__ChapterI__0893A34A262751EF");

                entity.ToTable("ChapterInfo");

                entity.Property(e => e.ChapterId).HasColumnName("ChapterID");

                entity.Property(e => e.ChapterType)
                    .IsRequired()
                    .HasMaxLength(2)
                    .IsUnicode(false)
                    .HasDefaultValueSql("((0))")
                    .IsFixedLength(true);

                entity.Property(e => e.ChapterUrl)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.ChapterWord)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.HasOne(d => d.Comics)
                    .WithMany(p => p.ChapterInfos)
                    .HasForeignKey(d => d.ComicsId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ChapterIn__Comic__398D8EEE");
            });

            modelBuilder.Entity<ChapterLikesInfo>(entity =>
            {
                entity.HasKey(e => e.ChapterLikesId)
                    .HasName("PK__ChapterL__51D066C3C156325C");

                entity.ToTable("ChapterLikesInfo");

                entity.Property(e => e.ChapterLikesId).HasColumnName("ChapterLikesID");

                entity.Property(e => e.ChapterId).HasColumnName("ChapterID");

                entity.Property(e => e.ChapterLikesType).HasDefaultValueSql("((0))");

                entity.Property(e => e.UserId).HasColumnName("UserID");

                entity.HasOne(d => d.Chapter)
                    .WithMany(p => p.ChapterLikesInfos)
                    .HasForeignKey(d => d.ChapterId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ChapterLi__Chapt__4CA06362");

                entity.HasOne(d => d.User)
                    .WithMany(p => p.ChapterLikesInfos)
                    .HasForeignKey(d => d.UserId)
                    .HasConstraintName("FK__ChapterLi__UserI__4BAC3F29");
            });

            modelBuilder.Entity<CollectionInfo>(entity =>
            {
                entity.HasKey(e => e.CollectionId)
                    .HasName("PK__Collecti__7DE6BC24CB4909E4");

                entity.ToTable("CollectionInfo");

                entity.Property(e => e.CollectionId).HasColumnName("CollectionID");

                entity.Property(e => e.CollectionTime)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.UserId).HasColumnName("UserID");

                entity.HasOne(d => d.Comics)
                    .WithMany(p => p.CollectionInfos)
                    .HasForeignKey(d => d.ComicsId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__Collectio__Comic__52593CB8");

                entity.HasOne(d => d.User)
                    .WithMany(p => p.CollectionInfos)
                    .HasForeignKey(d => d.UserId)
                    .HasConstraintName("FK__Collectio__UserI__5165187F");
            });

            modelBuilder.Entity<ComicsDownInfo>(entity =>
            {
                entity.HasKey(e => e.DownId)
                    .HasName("PK__ComicsDo__0A21D470151A0A98");

                entity.ToTable("ComicsDownInfo");

                entity.Property(e => e.DownId).HasColumnName("DownID");

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.DownTime)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.HasOne(d => d.Comics)
                    .WithMany(p => p.ComicsDownInfos)
                    .HasForeignKey(d => d.ComicsId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ComicsDow__Comic__36B12243");
            });

            modelBuilder.Entity<ComicsInfo>(entity =>
            {
                entity.HasKey(e => e.ComicsId)
                    .HasName("PK__ComicsIn__A49A99092F1FE80F");

                entity.ToTable("ComicsInfo");

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.ComicsAuthor)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.Property(e => e.ComicsEnd).HasMaxLength(30);

                entity.Property(e => e.ComicsImg)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.ComicsIntroduction)
                    .IsRequired()
                    .HasMaxLength(400);

                entity.Property(e => e.ComicsName)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsStart).HasMaxLength(30);

                entity.Property(e => e.ComicsTypeOne)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.ComicsTypeTwo)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.CountryId).HasColumnName("CountryID");

                entity.HasOne(d => d.Country)
                    .WithMany(p => p.ComicsInfos)
                    .HasForeignKey(d => d.CountryId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ComicsInf__Count__2B3F6F97");
            });

            modelBuilder.Entity<ComicsTypeInfo>(entity =>
            {
                entity.HasKey(e => e.ComicsTypeId)
                    .HasName("PK__ComicsTy__83C92804003B6243");

                entity.ToTable("ComicsTypeInfo");

                entity.Property(e => e.ComicsTypeId).HasColumnName("ComicsTypeID");

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.TypeId).HasColumnName("TypeID");

                entity.HasOne(d => d.Comics)
                    .WithMany(p => p.ComicsTypeInfos)
                    .HasForeignKey(d => d.ComicsId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ComicsTyp__Comic__300424B4");

                entity.HasOne(d => d.Type)
                    .WithMany(p => p.ComicsTypeInfos)
                    .HasForeignKey(d => d.TypeId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ComicsTyp__TypeI__30F848ED");
            });

            modelBuilder.Entity<ComicsUpInfo>(entity =>
            {
                entity.HasKey(e => e.UpId)
                    .HasName("PK__ComicsUp__5F6425B9865E8850");

                entity.ToTable("ComicsUpInfo");

                entity.Property(e => e.UpId).HasColumnName("UpID");

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.UpTime)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.HasOne(d => d.Comics)
                    .WithMany(p => p.ComicsUpInfos)
                    .HasForeignKey(d => d.ComicsId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ComicsUpI__Comic__33D4B598");
            });

            modelBuilder.Entity<ConmentInfo>(entity =>
            {
                entity.HasKey(e => e.ConmentId)
                    .HasName("PK__ConmentI__4A0DEE8A65D9A0A1");

                entity.ToTable("ConmentInfo");

                entity.Property(e => e.ConmentId).HasColumnName("ConmentID");

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.ConmentContent).HasMaxLength(200);

                entity.Property(e => e.ConmentTime).HasMaxLength(30);

                entity.Property(e => e.UserId).HasColumnName("UserID");

                entity.HasOne(d => d.Comics)
                    .WithMany(p => p.ConmentInfos)
                    .HasForeignKey(d => d.ComicsId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ConmentIn__Comic__3E52440B");

                entity.HasOne(d => d.User)
                    .WithMany(p => p.ConmentInfos)
                    .HasForeignKey(d => d.UserId)
                    .HasConstraintName("FK__ConmentIn__UserI__3F466844");
            });

            modelBuilder.Entity<ConmentLikesInfo>(entity =>
            {
                entity.HasKey(e => e.LikesId)
                    .HasName("PK__ConmentL__C82065D2787FB0AA");

                entity.ToTable("ConmentLikesInfo");

                entity.Property(e => e.LikesId).HasColumnName("LikesID");

                entity.Property(e => e.ChapterConmentId).HasColumnName("ChapterConmentID");

                entity.Property(e => e.LikesType).HasDefaultValueSql("((0))");

                entity.Property(e => e.UserId).HasColumnName("UserID");

                entity.HasOne(d => d.ChapterConment)
                    .WithMany(p => p.ConmentLikesInfos)
                    .HasForeignKey(d => d.ChapterConmentId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__ConmentLi__Chapt__46E78A0C");

                entity.HasOne(d => d.User)
                    .WithMany(p => p.ConmentLikesInfos)
                    .HasForeignKey(d => d.UserId)
                    .HasConstraintName("FK__ConmentLi__UserI__45F365D3");
            });

            modelBuilder.Entity<CountryInfo>(entity =>
            {
                entity.HasKey(e => e.CountryId)
                    .HasName("PK__CountryI__10D160BFAF13AAAF");

                entity.ToTable("CountryInfo");

                entity.Property(e => e.CountryId).HasColumnName("CountryID");

                entity.Property(e => e.CountryName)
                    .IsRequired()
                    .HasMaxLength(20);
            });

            modelBuilder.Entity<HistoryInfo>(entity =>
            {
                entity.HasKey(e => e.HistoryId)
                    .HasName("PK__HistoryI__4D7B4ADD09F28530");

                entity.ToTable("HistoryInfo");

                entity.Property(e => e.HistoryId).HasColumnName("HistoryID");

                entity.Property(e => e.ChapterId).HasColumnName("ChapterID");

                entity.Property(e => e.HistoryTime)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.Property(e => e.UserId).HasColumnName("UserID");

                entity.HasOne(d => d.Chapter)
                    .WithMany(p => p.HistoryInfos)
                    .HasForeignKey(d => d.ChapterId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__HistoryIn__Chapt__5629CD9C");

                entity.HasOne(d => d.User)
                    .WithMany(p => p.HistoryInfos)
                    .HasForeignKey(d => d.UserId)
                    .HasConstraintName("FK__HistoryIn__UserI__5535A963");
            });

            modelBuilder.Entity<TypeInfo>(entity =>
            {
                entity.HasKey(e => e.TypeId)
                    .HasName("PK__TypeInfo__516F0395FD03FC2C");

                entity.ToTable("TypeInfo");

                entity.Property(e => e.TypeId).HasColumnName("TypeID");

                entity.Property(e => e.TypeName)
                    .IsRequired()
                    .HasMaxLength(20);
            });

            modelBuilder.Entity<UserInfo>(entity =>
            {
                entity.HasKey(e => e.UserId)
                    .HasName("PK__UserInfo__1788CCACC26D3D78");

                entity.ToTable("UserInfo");

                entity.Property(e => e.UserId).HasColumnName("UserID");

                entity.Property(e => e.CreatTime)
                    .IsRequired()
                    .HasMaxLength(20)
                    .HasDefaultValueSql("(getdate())");

                entity.Property(e => e.Email).HasMaxLength(20);

                entity.Property(e => e.Phone)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.Property(e => e.UserImg)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.UserName)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.Property(e => e.UserPwd)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.UserType)
                    .IsRequired()
                    .HasMaxLength(10);
            });

            modelBuilder.Entity<VChapterInfo>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("v_ChapterInfo");

                entity.Property(e => e.ChapterId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("ChapterID");

                entity.Property(e => e.ChapterUrl)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.ChapterWord)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");
            });

            modelBuilder.Entity<VClassification>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("v_Classification");

                entity.Property(e => e.ComicCtentent)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.ComicImgUrl)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.Comicitle)
                    .IsRequired()
                    .HasMaxLength(20);

                entity.Property(e => e.ComicsAuthor)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.ComicsName)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsTypeOneId)
                    .IsRequired()
                    .HasMaxLength(1)
                    .IsUnicode(false)
                    .HasColumnName("ComicsTypeOneID");

                entity.Property(e => e.ComicsTypeTwo)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.CountryId).HasColumnName("CountryID");

                entity.Property(e => e.Sums).HasColumnName("sums");

                entity.Property(e => e.TypeName)
                    .IsRequired()
                    .HasMaxLength(20);
            });

            modelBuilder.Entity<VComicsInfo>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("v_ComicsInfo");

                entity.Property(e => e.ComicCtentent)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.ComicImgUrl)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.Comicitle)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.Hs).HasColumnName("hs");
            });

            modelBuilder.Entity<VComicsInfoGx>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("v_ComicsInfo_GX");

                entity.Property(e => e.ComicCtentent)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.ComicImgUrl)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.Comicitle)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.Hs).HasColumnName("hs");
            });

            modelBuilder.Entity<VComicsInfoMx>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("v_ComicsInfo_MX");

                entity.Property(e => e.ComicCtentent)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.ComicImgUrl)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.Comicitle)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsId).HasColumnName("ComicsID");

                entity.Property(e => e.Hs).HasColumnName("hs");
            });

            modelBuilder.Entity<VComicsInfoSj>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("v_ComicsInfoSJ");

                entity.Property(e => e.ComicCtentent)
                    .IsRequired()
                    .HasMaxLength(3);

                entity.Property(e => e.ComicImgUrl)
                    .IsRequired()
                    .HasMaxLength(100);

                entity.Property(e => e.Comicitle)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ComicsId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("ComicsID");
            });
            modelBuilder.Entity<proc_detailedClass>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("proc_detailedClass");

                entity.Property(e => e.ComicImgUrl);

                entity.Property(e => e.ComicsIntroduction);

                entity.Property(e => e.Comicitle);

                entity.Property(e => e.ComicsAuthor);

                entity.Property(e => e.ComicsTypeOne);

                entity.Property(e => e.hs);

                entity.Property(e => e.CollectionJud);

                entity.Property(e => e.ChapterWord);
            });

            modelBuilder.Entity<proc_Classification>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("proc_Classification");

                entity.Property(e => e.ComicsName);

                entity.Property(e => e.ComicsAuthor);

                entity.Property(e => e.ComicsTypeOneID);

                entity.Property(e => e.ComicCtentent);

                entity.Property(e => e.sums);

                entity.Property(e => e.ComicsID);

                entity.Property(e => e.ComicsTypeTwo);

                entity.Property(e => e.ComicImgUrl);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
